<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <title>Recherche</title>
        <meta name="keywords" content="" />
        <meta name="description" content="" />
        <link rel="stylesheet" type="text/css" href="default.css" />
        <script type="text/javascript" src="jquery.js"></script>
        <script type="text/javascript" src="scripts.js"></script>

    </head>
    <body>
        <div id="upbg"></div>
        <div id="outer">

            <?php
            include 'header.php';
            include 'login.php';
            include 'menu.php';
            ?>
            <div id="content">

                <?php
                include_once 'connectBDD.php';
                if(isset($_POST['recherche'])){
                    $recherche = addslashes($_POST['recherche']);
                }else{
                    $recherche = '';
                }
                echo"<div id='recherche2'>
                    <ul>
                    <li id='liRes'>Tous les résultats</li>
                    <li>
                    <form method='post' action='recherche.php'>
                        
                        <input id='inputRecherche' type='text' class='text' maxlength='64' name='recherche' value=\"". $recherche ."\" spellcheck='false'
                               onfocus='javascript:clearRecherche2();
                            '/>
                        <button type='submit' class='submit' value='Search' />
                    </form>
                </div>
                <div class='barreChoix'>
                <ul>
                    <a href='javascript:rechercheMembres();'><li><img src='images/People-32.png' />Personnes</li></a>
                    <a href='javascript:rechercheEvents();'><li><img src='images/Event-search-32.png'/>Evenements</li></a>
                </ul>
                </div>";
                //Recherche Personnes
                $result = mysql_query("SELECT login, avatar_path FROM User where login LIKE '%" . $recherche. "%'");
                echo"<div id='resultRechMembres'>";
                if (mysql_num_rows($result) <= 0) {
                    echo "<div class='no_result_found'>Aucune personne ne correspond à votre recherche.</div>";
                } else {
                    while ($row = mysql_fetch_assoc($result)) {

                        echo"
                         <div id='membre'>
                            <div id='petite_image'>
                                <img src=" . $row['avatar_path'] . " width='50px' height='50px' />
                            </div>
                            <div id='login'><a href='profil.php?login=" . $row['login'] . "'>" . $row['login'] . "</a></div>
                         </div>";
                    }
                }
                echo"</div>";

                //Recherche évenements
                $result = mysql_query("SELECT id_event, name_event, flyer_path FROM Event where name_event LIKE '%" . $recherche . "%'");

                echo"<div id='resultRechEvents'>";
                if (mysql_num_rows($result) <= 0) {
                    echo "<div class='no_result_found'>Aucun évenement ne correspond à votre recherche.</div>";
                } else {
                    while ($row = mysql_fetch_assoc($result)) {
                        echo"
                         <div id='membre'>
                            <div id='petite_image'>
                                <img src=" . $row['flyer_path'] . " width='50px' height='50px' />
                            </div>
                            <div id='login'><a href='detailEvenement.php?idEvent=" . $row['id_event'] . "'>" . $row['name_event'] . "</a></div>
                         </div>";
                    }
                }
                echo"</div>";
                ?>

            </div>

            <?php
            include 'footer.php';
            ?>

    </body>
</html>

